﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

namespace ExSiteBuilder.Models
{
	public class JzPageBuilder
	{
		public JzPageBuilder(JzRenderContext context)
		{
			_context = context;
		}

		public void RenderPage(JzPage page)
		{
			_context.Write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
			_context.Write("<html>");
			_context.Write("<head>");
			_context.Write("<title>JZ示例页面</title>");
			_context.Write("</head>");
			_context.Write("<body id=\"thebody\" class=\"yui-skin-sam\">");
			_context.Write("</body>");
			_context.Write("</html>");
		}

		public void RenderMasterPage(JzMasterPage page)
		{
			_context.Write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
			_context.Write("<html>");
			_context.Write("<head>");
			_context.Write("<title>JZ示例母版页</title>");
			_context.Write("</head>");
			_context.Write("<body id=\"thebody\" class=\"yui-skin-sam\">");
			_context.Write("</body>");
			_context.Write("</html>");
		}

		private JzRenderContext _context;
	}

	public class JzRenderContext
	{
		public JzRenderType RenderType { get; set; }

		public JzRenderContext(HttpResponse response)
		{
			_response = response;
			_response.ContentEncoding = Encoding.UTF8;
			_response.ContentType = "text/html";
		}

		public void Write(string html)
		{
			_response.Write(html);
		}

		private HttpResponse _response;
	}

	public enum JzRenderType
	{
		Publish,
		Design,
	}
}
